<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>后台登录</title>
    <link href="../../favicon.ico" rel="Shortcut Icon">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layui/css/layui.css"/>
    <link rel="stylesheet" href="__PUBLIC__/css/login.css"/>
</head>
<body>
<div class="login">
    <form class="layui-form" action="" method="post">
        <h2>Welcome!</h2>
        <div class="layui-form-item">
            <input type="text" name="username" value="" lay-verify="required" lay-verType="Tips" placeholder="请输入用户名"
                   autocomplete="on" class="layui-input">
        </div>
        <div class="layui-form-item">
            <input type="password" name="password" value="" lay-verify="required" lay-verType="Tips" placeholder="请输入密码"
                   autocomplete="on" class="layui-input">
        </div>
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input type="text" name="captcha" value="" lay-verify="required" lay-verType="Tips" placeholder="请输入验证码"
                       autocomplete="off" class="layui-input">
            </div>
            <div style="float: right; margin-right: 0px;">
                <img src="{:captcha_src()}" id="captcha" onclick="this.src='{:captcha_src()}?seed='+Math.random()" height="38" width="150"
                     alt="captcha"/>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit lay-filter="login">登录</button>
        </div>
    </form>
</div>
<footer>©<php>echo Date('Y');</php>&nbsp;&nbsp;你家隔壁程序猿.<a href="http://www.zzuyxg.top" target="_blank" title="你家隔壁程序猿">www.zzuyxg.top</a>
</footer>
<script type="text/javascript" src="__STATIC__/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layer', 'jquery'], function () {
        var form = layui.form,
            layer = layui.layer;
        var $ = layui.jquery;

        var href = "{:url('admin/index/index')}";

        form.on('submit(login)', function (data) {
            $.post("{:url('admin/public/doLogin')}", data.field, function (res) {
                if (res.code == 1) { //验证通过，跳转到refer指定的地址
                    layer.msg(res.msg, {icon: 6}, function () {
                        window.location.href = href;
                    });
                } else {
                    layer.msg(res.msg, {icon: 5}, function () {
                        $('#captcha').attr('src', "{:captcha_src()}");
                        return false;
                    });
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
